package earogya.pharmacy.request_for_drugs.ws;

import java.io.IOException;

import ca.uhn.hl7v2.HL7Exception;
import earogya.pharmacy.request_for_drugs.ws.HL7MessageHandler;

public class RequestForDrugsServiceInterface {

	public String requestForDrugsMessage(String msg) throws HL7Exception,
			IOException {

		HL7MessageHandler h = new HL7MessageHandler();
		String message = "MSH|^~\\&|GUI|CSTH|PHA|CSTH|20110610101010||RDE^O11||P|2.5.1\r"
				+ "EVN|O01|20030822172800|||1\r"
				+ "ORC|NE|1001^12|9999999^RX|||E|40^Q6H^10||20110610101010|1234|1235||PHR\r"
				+ "RXO|1120^urgent|500|500|mg||||ETU|Y\r";
		String newMessage=this.modifyMessage(msg);
		String ack=h.parser(newMessage);
		return ack;
	}

	private String modifyMessage(String message) {
		String newMessage = null;
		newMessage = message.replaceAll("\n", "\r");
		return newMessage;
	}

	/*
	 * Request_For_Drugs rfd = new Request_For_Drugs(); rfd.setDrugId(1);
	 * rfd.setQuantity(30); rfd.setUnitOrWard("Mental Ward - No.18");
	 * rfd.setUrgency("Serious"); rfd.setRequestId(1); rfd.setRequestDate(new
	 * Date(2011/10/12)); rfd.setRequestTime(new Time(1500));
	 * 
	 * 
	 * Session session =
	 * RequestForDrugsHibernateUtil.getSessionFactory().getCurrentSession();
	 * try{ session.beginTransaction(); session.save(rfd);
	 * session.getTransaction().commit(); }catch(HibernateException e){
	 * e.printStackTrace(); }finally{ }
	 * 
	 * return msg;
	 * 
	 * /*public String getName(String name){ return name; }
	 */
}
